﻿Imports Microsoft.VisualBasic
Imports System.Data
Imports System.ComponentModel
Public Class Reconocimientos
    Inherits BDDatos
    Sub New()
        Me.Tabla = ""
        Me.Vista = ""
    End Sub
    Public TIPO_REC As String
    Public DESCRIPCION As String
    Public FECHA As String
    Public OTORGADO_POR As String
    Public IDPK As String
    Public Function Insert() As String
        Me.Conectar()
        Me.ComenzarTransaccion()
        Try
            Me.querystring = "Insert into RECONOCIMIENTOS(Cedula, Tipo_Rec,Descripcion,Fecha, Otorgado_Por)" & _
            "Values(:Cedula, :Tipo_Rec, :Descripcion, :Fecha, :Otorgado_Por)"
            Me.CrearComando(querystring)
            Me.AsignarParametroCadena(":Cedula", Me.usuario)
            Me.AsignarParametroCadena(":Tipo_Rec", Me.Tipo_Rec)
            Me.AsignarParametroCadena(":Descripcion", Descripcion)
            Me.AsignarParametroCadena(":Fecha", Me.Fecha)
            Me.AsignarParametroCadena(":Otorgado_Por", Me.Otorgado_Por)
            Me.num_reg = EjecutarComando()
            Me.Msg = "Se realizo la Operacion Exitosamente - " + num_reg.ToString + " Filas Afectadas"
            Me.lErrorG = False
            Me.ConfirmarTransaccion()
        Catch ex As Exception
            CancelarTransaccion()
            Me.lErrorG = True
            Me.Msg = "Err: " + ex.Message
        Finally
            Me.Desconectar()
        End Try
        Return Msg
    End Function
    Public Function Update() As String
        Me.Conectar()
        Me.ComenzarTransaccion()
        Try
            Me.querystring = "Update RECONOCIMIENTOS set Tipo_Rec=:Tipo_Rec, Descripcion=:Descripcion, Fecha=:Fecha, Otorgado_Por=:Otorgado_Por Where ID=:ID And Cedula=:Cedula"
            Me.CrearComando(querystring)
            Me.AsignarParametroCadena(":Cedula", Me.usuario)
            Me.AsignarParametroCadena(":Tipo_Rec", Me.TIPO_REC)
            Me.AsignarParametroCadena(":Descripcion", DESCRIPCION)
            Me.AsignarParametroCadena(":Fecha", Me.FECHA)
            Me.AsignarParametroCadena(":Otorgado_Por", Me.OTORGADO_POR)
            Me.AsignarParametroCadena(":ID", Me.IDPK)
            Me.num_reg = EjecutarComando()
            Me.Msg = "Se realizo la Operacion Exitosamente - " + num_reg.ToString + " Filas Afectadas"
            Me.lErrorG = False
            Me.ConfirmarTransaccion()
        Catch ex As Exception
            CancelarTransaccion()
            Me.lErrorG = True
            Me.Msg = "Err: " + ex.Message
        Finally
            Me.Desconectar()
        End Try
        Return Msg
    End Function
    <DataObjectMethodAttribute(DataObjectMethodType.Select, True)> _
    Public Function GetxEgresado() As DataTable
        Me.Conectar()
        Me.querystring = "Select * from VRECONOCIMIENTOS where cedula=:cedula"
        CrearComando(querystring)
        Me.AsignarParametroCadena(":cedula", Me.usuario)
        Dim dt As DataTable = EjecutarConsultaDataTable()
        Me.Desconectar()
        Return dt
    End Function
    <DataObjectMethodAttribute(DataObjectMethodType.Select, True)> _
    Public Function GetxEgresado(ByVal Cedula As String) As DataTable
        Me.Conectar()
        Me.querystring = "Select * from VRECONOCIMIENTOS where cedula=:cedula"
        CrearComando(querystring)
        Me.AsignarParametroCadena(":cedula", Cedula)
        Dim dt As DataTable = EjecutarConsultaDataTable()
        Me.Desconectar()
        Return dt
    End Function
    <DataObjectMethodAttribute(DataObjectMethodType.Select, True)> _
    Public Function GetbyPK(ByVal ID As String) As DataTable
        Me.Conectar()
        Me.querystring = "Select * from VRECONOCIMIENTOS where cedula=:cedula and ID=:ID"
        CrearComando(querystring)
        Me.AsignarParametroCadena(":cedula", Me.usuario)
        Me.AsignarParametroCadena(":ID", ID)
        Dim dt As DataTable = EjecutarConsultaDataTable()
        Me.Desconectar()
        Return dt
    End Function
    Public Function Delete(ByVal ID As String) As String
        Me.Conectar()
        Me.ComenzarTransaccion()
        Try
            Me.querystring = "Delete from RECONOCIMIENTOS where ID=:ID and Cedula=:Cedula"
            Me.CrearComando(querystring)
            Me.AsignarParametroCadena(":ID", ID)
            Me.AsignarParametroCadena(":Cedula", Me.usuario)
            Me.num_reg = EjecutarComando()
            Me.Msg = "Se realizo la Operacion Exitosamente - " + num_reg.ToString + " Filas Afectadas"
            Me.lErrorG = False
            Me.ConfirmarTransaccion()
        Catch ex As Exception
            CancelarTransaccion()
            Me.lErrorG = True
            Me.Msg = "Err: " + ex.Message
        Finally
            Me.Desconectar()
        End Try
        Return Msg
    End Function
End Class
